<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('员工列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>员工工号：</label>
                                <input  name="empNum" />
                            </li>
                            <li>
                                <label>姓名：</label>
                                <input type="text" name="empName"/>
                            </li>
                            <li>
                                <label>性别：</label>
                                <select id="sex" name="sex" th:with="type=${@dict.getType('sys_user_sex')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>手机号码：</label>
                                <input   maxlength="11" type="number" name="phonenumber"/>
                            </li>
                            <li>
                                <label>教育背景：</label>
                                <select id="education" name="education" th:with="type=${@dict.getType('sys_education')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select id="empStatus" name="empStatus" th:with="type=${@dict.getType('sys_emp_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>岗位：</label>
                                <select id="postId" name="postId" class="form-control m-b" th:with="postAll=${@postService.getPostAll()}">
                                    <option value="">所有</option>
                                    <option th:each="post : ${postAll}" th:text="${post.getPostName()}" th:value="${post.getPostId()}"  th:hidden="${post.getStatus() == '1'}"></option>
                                </select>
                            </li>

                            <!--<li>
                                <label>所属部门：</label>
                                <select id="deptId" name="deptId" class="form-control m-b" th:with="deptAll=${@deptService.getDeptAll()}">
                                    <option value="">所有</option>
                                    <option th:each="dept : ${deptAll}" th:text="${dept.getShowName()}" th:value="${dept.getDeptId()}"  th:hidden="${dept.getStatus() == '1' || dept.getDelFlag() != '0' }"></option>
                                </select>
                            </li>-->
                            <div th:include="include/deptSearch::deptSearch"></div>
                        <!--    <li>
                                <label>身份证号码：</label>
                                <input type="text" maxlength="20"  name="idNumber"/>
                            </li>


                            <li>
                                <label>紧急联系人：</label>
                                <input type="text" name="contactsName"/>
                            </li>
                            <li>
                                <label>联系人电话：</label>
                                <input type="text" name="contactsPhone"/>
                            </li>
                            <li>
                                <label>联系人地址：</label>
                                <input type="text" name="contactsAddresss"/>
                            </li>
                            <li>
                                <label>专业：</label>
                                <input type="text" name="major"/>
                            </li>
                            <li>
                                <label>持有证书：</label>
                                <input type="text" name="certificate"/>
                            </li>
                            &lt;!&ndash;<li class="select-time">
                                <label>毕业时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginGraduationDate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endGraduationDate]"/>
                            </li>&ndash;&gt;
                            <li>
                                <label>开户行支行：</label>
                                <input type="text" name="bankBranch"/>
                            </li>
                            <li>
                                <label>银行卡号：</label>
                                <input type="text" name="bankNumber"/>
                            </li>
-->
                            <li>
                                <!--<label>所属城市：</label>
                                <input name="city" class="form-control cityValue" type="hidden" >
                                <div class="searchCitySelect">
                                </div>-->

                                <div class="form-group" style="width: 310px;display: flex;">
                                    <label class="control-label">城市：</label>
                                    <div class="col-sm-10" style="margin-left: -52px;">
                                        <input name="city" class="form-control cityValue" type="hidden" required>
                                        <div class="searchCitySelect">
                                        </div>
                                    </div>
                                </div>

                            </li>
                            <li style="margin-left: 71px;">
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="employee:emp:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editFull()" shiro:hasPermission="employee:emp:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="employee:emp:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="employee:emp:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="employee:emp:import">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="downTemplate()" shiro:hasPermission="employee:emp:export">
                    <i class="fa fa-download"></i> 下载模板
                </a>
                <a class="btn btn-info" onclick="$.modal.open('上传照片','/employee/emp/toUploadZIP')" shiro:hasPermission="employee:emp:import">
                    <i class="fa fa-upload"></i> 上传照片
                </a>
                <!--<a class="btn btn-success" onclick="checkItem()">
                    <i class="fa fa-check"></i> 选中项
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('employee:emp:edit')}]];
        var removeFlag = [[${@permission.hasPermi('employee:emp:remove')}]];
        var prefix = ctx + "employee/emp";

        $(function() {
            // debugger
            var sexMap = {};
            $('#sex option').each(function(i, n){
                sexMap[$(n).val()] = $(n).text();
            });

            var empStatusMap = {};
            $('#empStatus option').each(function(i, n){
                empStatusMap[$(n).val()] = $(n).text();
            });

            var deptIdMap = {};
            $('#deptId option').each(function(i, n){
                deptIdMap[$(n).val()] = $(n).text();
            });

            var postIdsMap = {};
            $('#postId option').each(function(i, n){
                postIdsMap[$(n).val()] = $(n).text();
            });

            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                modalName: "员工",
                uniqueId: "empId",
                rememberSelected: true,
                columns: [{
                    field: 'state',
                    checkbox: true
                },
                {
                    field: 'userId', 
                    title: '员工id',
                    visible: false

                },
                {
                    field: 'empNum',
                    title: '员工工号'

                },

                {
                    field: 'empName', 
                    title: '员工姓名'
                }, {
                        field: 'deptName',
                        title: '所属部门'

                    },{
                        field: 'city',
                        title: '所属城市'
                    },
                    {
                        field: 'postId',
                        title: '岗位',
                        formatter: function(val, row, index){return postIdsMap[val];}
                    },
                    {
                        field: 'phonenumber',
                        title: '手机号码'
                    },
                    {
                        field: 'nonManagerDate',
                        title: '入职日期'
                    },{
                        field: 'quitDate',
                        title: '离职时间'
                    },
                {
                    field: 'sex',
                    title: '用户性别',
                    formatter: function(val, row, index){return sexMap[val];}
                },
                    {
                        field: 'idNumber',
                        title: '身份证号码'
                    },

                    {
                        field: 'birthday',
                        title: '出生日期'
                    },
                {
                    field: 'email',
                    title: '邮箱',
                    visible: false
                },

                    {
                        field: 'education',
                        title: '教育背景'
                    }, {
                        field: 'graduation',
                        title: '毕业学校'
                    },
                    {
                        field: 'nowResidence',
                        title: '现居地址'
                    },
                    {
                        field: 'empStatus',
                        title: '状态',
                        formatter: function (val, row, index) {
                            return empStatusMap[val];
                        }

                    },

               /* {
                    field: 'ethnic', 
                    title: '名族'
                },

                {
                    field: 'health', 
                    title: '健康状态'
                },
                {
                    field: 'nowResidence', 
                    title: '现居住地'
                },
                {
                    field: 'education', 
                    title: '教育背景'
                },
                {
                    field: 'nationality', 
                    title: '国籍'
                },

                {
                    field: 'information', 
                    title: '基本情况'
                },
                {
                    field: 'description', 
                    title: '特长描述'
                },

                {
                    field: 'createId', 
                    title: '创建者id'
                },
                {
                    field: 'updateId', 
                    title: '更新者id'
                },*/
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.empId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.empId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function reset() {

            $('.cityName').text( "不限");
            $('.cityValue').val("");

            $.form.reset()
        }

        function downTemplate() {
            var url = "/docs/employeeTemplate.xlsx";
            window.location.href = url;
        }

        // 选中数据
        function checkItem(){
            // var arrays = $.table.selectColumns("userId");
            var arrays = $.table.selectColumns("userId");
            alert(arrays);
        }

    </script>
     <!-- 导入区域 -->
     <script id="importTpl" type="text/template">
         <form enctype="multipart/form-data" class="mt20 mb10">
             <div class="col-xs-offset-1">
                 <input type="file" id="file" name="file"/>
                 <!--<div class="mt10 pt5">
                     <a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"></a>
                 </div>-->
                 <font color="red" class="pull-left mt10">
                     提示：仅允许导入“xls”或“xlsx”格式文件！
                 </font>
             </div>
         </form>
     </script>
</body>
</html>